{include file="public/header" /}
<body class="gray-bg">
<div class="wrapper wrapper-content">
    <div class="ibox float-e-margins">
        <div class="ibox-content">
            <div class="row">
                <!--搜索框开始-->
                <div class="col-sm-12">
                    <div class="layui-form layui-form-item">

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="update_start" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="更新开始时间"/>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <input type="text"  name="update_end" onfocus="wk.lay_date(this);" class="layui-input layer-date search" placeholder="更新结束时间"/>
                        </div>

                        <div class="layui-col-md6 layui-input-inline" style="margin-top: 5px">
                            <input type="text" id="keyword" class="layui-input search" name="keyword" value="" placeholder="ID|书名|作者"/>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="rb_status" id="rb_status" lay-search="" class="layui-input">
                                <option  value="">不限状态</option>
                                <option  value="1">上架中</option>
                                <option  value="2">已下架</option>
                            </select>
                        </div>

                        <div class="layui-input-inline layui-form" style="margin-top: 5px">
                            <select name="grade_id" id="grade_id" lay-search="" class="layui-input">
                                <option  value="">不限年级</option>
                                {volist name="grade" id="vo"}
                                <option  value="{$vo.grade_id}">{$vo.grade_name}</option>
                                {/volist}
                            </select>
                        </div>

                        <div class="layui-input-inline" style="margin-top: 5px">
                            <button class="layui-btn" lay-submit="" lay-filter="LAY-search">立即搜索</button>
                            <button  class="layui-btn layui-btn-normal" id="empty"  lay-submit="" lay-filter="LAY-search">重置</button>
                        </div>
                    </div>
                </div>
                <!--搜索框结束-->
                <!--操作框开始-->
                <div class="col-sm-12">
                    <div class="input-group" >
                        <button  class="btn btn-danger m-l-xs" href="javascript:;" data-toggle="dropdown">
                            <i class="fa fa-wrench"></i> 批量操作 <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu layui-anim layui-anim-upbit" role="menu">
                            <li><a href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-check-circle"></i> 批量导入 </a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="usingAllS"><i class="fa fa-ban"></i> 批量上架</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="batchForbiddenS"><i class="fa fa-trash-o"></i> 批量下架</a></li>
                            <li><a  href="javascript:;" class="layuiBtn" data-type="batchDel"><i class="fa fa-trash-o"></i> 批量删除</a></li>
                            <!--<li><a  href="javascript:;" class="layuiBtn" data-type="excelIn"><i class="fa fa-external-link"></i> 批量导入</a></li>-->
                        </ul>
                    </div>
                </div>
                <!--操作框结束-->
            </div>
            <div class="hr-line-dashed"></div>

            <div class="example-wrap">
                <div class="example">
                    <table class="layui-hide" id="test" lay-filter="demo"></table>

                    <!--修改状态模板-->
                    <!--<script type="text/html" id="staBar">-->
                    <!--<input type="checkbox" value="{{d.school_id}}"  lay-skin="switch"  lay-text="上架中|已下架" lay-filter="OnOff" {{ d.school_status == 1 ? 'checked' : '' }} >-->
                    <!--</script>-->

                    <!--状态显示模板-->
                    <script type="text/html" id="imgTpl">
                        <img src="{{d.rb_image}}" class="img-circle table-img" onerror="this.src='/static/admin/images/head_default.gif'"  />
                    </script>
                    <!--操作模板-->
                    <script type="text/html" id="opeBar">
                        <a href="javascript:;" onclick="wk.href('{:url('update')}?id={{d.rb_id}}')" class="btn btn-warning btn-xs m-r-xs">编辑</a>
                        <a href="javascript:;" onclick="wk.href('{:url('essential')}?id={{d.rb_id}}')" class="btn btn-warning btn-xs m-r-xs">基本信息</a>
                        <a href="javascript:;" onclick="wk.href('{:url('start')}?id={{d.rb_id}}')" class="btn btn-warning btn-xs m-r-xs">开启信息</a>
                        <a href="javascript:;" onclick="wk.href('{:url('checkpoint')}?id={{d.rb_id}}')" class="btn btn-warning btn-xs m-r-xs">关卡信息</a>
                        <!--<a href=""  class="btn btn-primary  btn-xs m-r-xs">下载</a>-->
                    </script>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="public/footer" /}
<script>
    //layui渲染数据表格
    layui.use('table', function () {
        var table = layui.table
                , form = layui.form;
        table.render({
            elem: '#test'
            , url: '{:url("book/index")}'
            ,response: {
                statusCode: 220 //成功的状态码，默认：0
            }
            , page: true
            , size: 'lg' //sm小尺寸的表格 lg大尺寸
            , cellMinWidth: 150
            , limits: [5, 10, 15, 20, 25, 30]
            , limit: "{:config('pages')}"
            , loading: true
            , id: 'testReload'
            , cols: [[
                {type: 'checkbox', fixed: 'left',}
                , {type:'numbers', width: 80, title: '序号'}
                , {field: 'rb_id', width: 80, title: 'ID', align: 'center'}
                , {field: 'rb_image', width: 100, title: '图片', align: 'center', templet: '#imgTpl'}
                , {field: 'rb_name', width: 100, title: '书名', align: 'center'}
                , {field: 'rb_book_type_name', width: 100, title: '书名类型', align: 'center'}
                , {field: 'rb_status_name', width: 100, title: '使用状态', align: 'center'}
                , {field: 'rb_author', width: 100, title: '作者', align: 'center'}
                , {field: 'rb_company', width: 150, title: '出版社', align: 'center'}
                , {field: 'rb_version', width: 150, title: '版本', align: 'center'}
                , {field: 'grade_name', width: 200, title: '适应年级', align: 'center'}
                , {field: 'rb_score', width: 100, title: '评分', align: 'center'}
                , {field: 'num', width: 100, title: '关卡数', align: 'center'}
                , {field: 'rb_type_name', width: 150, title: '是否设为默认书籍', align: 'center'}
                , {field: 'member_num', width: 150, title: '开启人数', align: 'center'}
                , {field: 'rb_pass', width: 150, title: '已闯关人数', align: 'center'}
                , {field: 'rb_update_time', width: 200, title: '更新时间', align: 'center'}
                , {fixed: 'right', width:300, title: '操作', align: 'center', toolbar: '#opeBar'}
            ]]
        });
        //批量操作
        var $ = layui.$, active = {
            //批量上架
            usingAllS: function(){
                wk.usingAllS(getIds(),1,"{:url('couponStatus')}");
            },
            //批量下架
            batchForbiddenS: function(){
                wk.batchForbiddenS(getIds(),2,"{:url('couponStatus')}");
            },
            //批量导入excel
            excelIn: function(){
                location.href = "{:url('excelIn')}";
            },
            //批量删除
            batchDel:function () {
                wk.batchDel(getIds(),"{:url('del')}");
            }
        };
        $('.layuiBtn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        var getIds = function () {
            var ids = [];
            var checkStatus = table.checkStatus('testReload')
                    ,data = checkStatus.data;
            $.each(data,function(index,item){
                ids.push(item['rb_id'])
            });
            return ids;
        }
    });
</script>
</body>
</html>